package test.com.sms.selenium.singlepoint.util;

import org.openqa.selenium.By;

import test.com.sms.selenium.framework.SeleniumPageUtil;
import test.com.sms.selenium.util.SeleniumUtil;

public class SpIncidentEditSroTabPageUtil extends SeleniumPageUtil {

	public final static By IES_SPAN_SRO_HEAD = By.id("SRO_Header_lblHeader");
	public final static By IES_LINK_SAVE = By.xpath("//*[@id='0476f4c1-4ba9-4f14-9f2b-01f0086d51cd']/a");
	public final static By IES_SPAN_SRO = By.id("SRO_lblSRONumber");
	public final static By IES_INPUT_SRO = By.id("SRO_txtSroHeaderNumber");
	public final static By IES_LINK_REPORT = By.id("SRO_hlServiceActivityReport");
	public final static By IES_SPAN_INCIDENT = By.id("SRO_lblIncident");
	public final static By IES_LINK_INCIDENT = By.id("SRO_hlIncidentNumber");
	public final static By IES_SPAN_CUSTOMER = By.id("SRO_lblCustomer");
	public final static By IES_INPUT_CUSTOMER = By.id("SRO_txtCustomerName");
	public final static By IES_SPAN_SRO_TYPE = By.id("SRO_lblSroType");
	public final static By IES_SELECT_SRO_TYPE = By.id("SRO_cboSroType");
	public final static By IES_SPAN_CUS_TIKET = By.id("SRO_lblCustomerTicket");
	public final static By IES_INPUT_CUS_TIKET = By.id("SRO_lblCustomerTicketNumber");
	public final static By IES_SPAN_CURRNECY = By.id("SRO_lblCurrency");
	public final static By IES_SPAN_CURR_VALUE = By.id("SRO_lblCustomerCurrency");
	public final static By IES_SPAN_SRO_STATUS = By.id("SRO_lblSroStatus");
	public final static By IES_SELECT_SRO_STATUS = By.id("SRO_cboSroHeaderStatus");
	public final static By IES_BTN_RE_OPEN = By.id("SRO_btnSroStatusToggle");
	public final static By IES_SPAN_DESC = By.id("SRO_lblDescription");
	public final static By IES_INPUT_DESC = By.id("SRO_txtSroHeaderDescription");
	public final static By IES_SPAN_SRO_NUM = By.id("SRO_lblPONumber");
	public final static By IES_TD_SRO_NUM = By.xpath("//*[@id='column3']/table/tbody/tr[3]/td[2]");
	public final static By IES_SELECT_SRO_NUM = By.id("SRO_cboPurchaseOrder");
	public final static By IES_INPUT_SRO_NUM = By.id("SRO_txtPONumber");
	public final static By IES_SPAN_OPENED = By.id("SRO_lblOpened");
	public final static By IES_INPUT_OPENED = By.id("SRO_txtDateOpened");
	public final static By IES_SPAN_WARE_HOUSE = By.id("SRO_lblWarehouse");
	public final static By IES_SELECT_WARE_HOUSE = By.id("SRO_cboSroHeaderWarehouse");
	
	public final static By IES_SPAN_SHIP_TO = By.id("SRO_lblShipTo");
	public final static By IES_IMG_SHIP_MAP = By.id("SRO_ShipToAddress_imgMap");
	public final static By IES_IMG_SHIP_SELECT = By.id("SRO_ShipToAddress_imgSelect");
	public final static By IES_SPAN_SHIP_ADD = By.id("SRO_ShipToAddress_lblName");
	public final static By IES_SPAN_SHIP_ADD_DIS = By.id("SRO_ShipToAddress_lblDisplay");
	
	public final static By IES_SPAN_CLOSE = By.id("SRO_lblClosed");
	public final static By IES_INPUT_CLOSE = By.id("SRO_txtDateClosed");
	public final static By IES_SPAN_ASS_TO = By.id("SRO_lblAssignedTo");
	public final static By IES_INPUT_ASS_TO = By.id("SRO_txtAssignedTo");
	
	public final static By IES_SPAN_BILL_MANAGER = By.id("SRO_lblBillManager");
	public final static By IES_SELECT_BILL_MANAGER = By.id("SRO_cboBillManager");
	public final static By IES_SPAN_NOTES = By.id("SRO_lblNotes");
	public final static By IES_TEXTAREA_NOTES = By.id("SRO_txtHeaderNotes");
	public final static By IES_SPAN_BILL_TO = By.id("SRO_lblBillTo");
	public final static By IES_IMG_BILL_MAP = By.id("SRO_BillToAddress_imgMap");
	public final static By IES_IMG_BILL_SELECT = By.id("SRO_BillToAddress_imgSelect");
	public final static By IES_SPAN_BILL_ADD = By.id("SRO_BillToAddress_lblName");
	public final static By IES_SPAN_BILL_ADD_DIS = By.id("SRO_BillToAddress_lblDisplay");
	
	//line & operation
	public final static By IES_SPAN_LINE  = By.id("SRO_lblCurrentLineOperation");
	public final static By IES_LINK_SHOW_LINE  = By.id("SRO_lblShowLinesOperations");
	public final static By IES_SPAN_SRO_LINE  = By.id("SRO_lblSroLine");
	public final static By IES_LINK_HIDE_LINE  = By.id("SRO_lblHideLinesOperations");
	
	public final static By IES_SPAN_LINE_NUM  = By.id("SRO_lblLineNumberDescription");
	public final static By IES_SELECT_LINE_NUM  = By.id("SRO_cboLines");
	public final static By IES_SPAN_LINE_STATUS  = By.id("SRO_lblLineStatus");
	public final static By IES_INPUT_LINE_STATUS  = By.id("SRO_txtLineStatus");
	public final static By IES_SPAN_LINE_DESC = By.id("SRO_lblLineDescription");
	public final static By IES_INPUT_LINE_DESC = By.id("SRO_txtLineDescription");
	public final static By IES_BTN_LINE_SAVE = By.id("SRO_btnLineSave");
	public final static By IES_BTN_LINE_NOTE = By.id("SRO_btnShowNotes");
	
	//operation
	public final static By IES_SPAN_OPER = By.id("SRO_lblSroOperation");
	public final static By IES_SPAN_OPER_DESC = By.id("SRO_lblOperationNumberDescription");
	public final static By IES_SELECT_OPER_DESC = By.id("SRO_cboOperations");
	public final static By IES_SPAN_OPER_STATUS = By.id("SRO_lblOperationStatus");
	public final static By IES_INPUT_OPER_STATUS = By.id("SRO_txtOperationStatus");
	
	//transaction
	public final static By IES_SPAN_TRA = By.id("SRO_lblTransactions");
	
	//labor
	public final static By IES_SPAN_LABOR = By.xpath("//*[@id='SRO_lblTransactionList']/table/tbody/tr[1]/td[1]");
	public final static By IES_LINK_TIME_CARD = By.xpath("//*[@id='SRO_lblTransactionList']/table/tbody/tr[1]/td[2]/a");
	
	//table list
	public final static By IES_TD_DATE = By.xpath("//*[@id='SRO_lblTransactionList']/table/tbody/tr[2]/td[5]");
	public final static By IES_TD_USER = By.xpath("//*[@id='SRO_lblTransactionList']/table/tbody/tr[2]/td[6]");
	public final static By IES_TD_DEPT = By.xpath("//*[@id='SRO_lblTransactionList']/table/tbody/tr[2]/td[7]");
	public final static By IES_TD_CODE = By.xpath("//*[@id='SRO_lblTransactionList']/table/tbody/tr[2]/td[8]");
	public final static By IES_TD_BILL_CODE = By.xpath("//*[@id='SRO_lblTransactionList']/table/tbody/tr[2]/td[9]");
	public final static By IES_TD_HRS = By.xpath("//*[@id='SRO_lblTransactionList']/table/tbody/tr[2]/td[11]");
	public final static By IES_TD_UNIT_COST = By.xpath("//*[@id='SRO_lblTransactionList']/table/tbody/tr[2]/td[12]");
	public final static By IES_TD_UNIT_PRICE = By.xpath("//*[@id='SRO_lblTransactionList']/table/tbody/tr[2]/td[13]");
	public final static By IES_TD_COST = By.xpath("//*[@id='SRO_lblTransactionList']/table/tbody/tr[2]/td[14]");
	public final static By IES_TD_PRICE = By.xpath("//*[@id='SRO_lblTransactionList']/table/tbody/tr[2]/td[15]");
	public final static By IES_TD_POSTING = By.xpath("//*[@id='SRO_lblTransactionList']/table/tbody/tr[2]/td[16]");
	public final static By IES_TD_EXPENSE = By.xpath("//*[@id='SRO_lblTransactionList']/table/tbody/tr[2]/td[17]");
	public final static By IES_TD_INVOICE= By.xpath("//*[@id='SRO_lblTransactionList']/table/tbody/tr[2]/td[18]");
	public final static By IES_TD_SYNC = By.xpath("//*[@id='SRO_lblTransactionList']/table/tbody/tr[2]/td[19]");
	
	public final static By IES_TD_TOTAL = By.xpath("//*[@id='SRO_lblTransactionList']/table/tbody/tr[7]/td[10]");
	public final static By IES_BTN_POST = By.id("POST_BUTTON_LABOR");
	public final static By IES_TD_GRANT_TOTAL = By.xpath("//*[@id='SRO_lblTransactionList']/table/tbody/tr[11]/td[10]");
	public static void enterSroTab(String incidentId){
		// login into homepage
		SpSearchPageUtil.enter();
		// current window handle
		// make sure search button and incident id input text show
		SeleniumUtil.assertTrue(SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(SpIncidentEditPageUtil.IE_BUTTON_SEARCH)));
		SeleniumUtil.assertTrue(SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(SpIncidentEditPageUtil.IE_MAIN_INPUT_INCIDENT_ID)));
		// click the incident id link to enter the edit page
		SpIncidentEditPageUtil.enterIncidentID(incidentId);
		//click Assets link to enter incident/Asset edit page
		SeleniumUtil.click(SeleniumUtil.getCachedElement(SpIncidentEditPageUtil.IE_LINK_TAB_SRO));
		waitForPageToLoad();
	}
	public static void waitForPageToLoad(){
		SeleniumUtil.selectDefaultContent();
		SeleniumUtil.waitOnElements(new By[]{
				IES_LINK_SAVE,IES_TEXTAREA_NOTES
		});
		SeleniumUtil.isDisplayed(SeleniumUtil.findElement(IES_TEXTAREA_NOTES));
	}
}
